<template>
	<view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			this.handleLogin()
		},
		methods: {
			handleLogin(e) {
				uni.showLoading({
					title: '登陆中'
				})
				uni.login({
					provider: 'weixin',
					success: res => {
						console.log(res)
						console.log(res.code)
						if (res.code) {
							//发起网络请求
							// this.code = res.code
			
							this.$http2.post('auth/wx/code2login', {
								code: res.code,
								authType: 3
							}).then(res => {
								console.log(res)
								if (res.code === 40004) {
									uni.hideLoading()
									// uni.setStorageSync('authkey', res.data.authkey)
									// uni.setStorageSync('authType', res.data.authType)
									uni.showModal({
										title: '提示',
										content: '用户不存在,请前往账号验证',
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												uni.navigateTo({
													url: '../login/login'
												})
											} 
										}
									});
									// this.showModal('用户不存在,请进行手机号验证','../phone/phone')
								} else if (res.code === 10000) {
									uni.hideLoading()
									// uni.showToast({
									// 	title: '登录成功'
									// })
									// this.getUserInfo()
								}
							})
						} else {
							console.log('登录失败！' + res.errMsg)
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>
